package ooday04;

public class AnimalTest {
    public static void main(String[] args) {

        Animal[] animals=new Animal[3];
        animals[0]=new Dog("修够",1,"灰");
        animals[1]=new Chick("坤坤",2,"黑白相间");
        animals[2]=new Fish("小鱼儿",3,"红");
        for(int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].drink();
            animals[i].eat();
            if(animals[i] instanceof Swim){
             Swim swim=(Swim)animals[i];
             swim.swim();
            }
            if(animals[i] instanceof Dog){
                Dog dog=(Dog)animals[i];
                dog.lookHome();
            }
            if(animals[i] instanceof Chick){
                Chick chick=(Chick)animals[i];
                chick.layEggs();
            }
        }

        Master master=new Master();
        master.feed(new Dog("修够",1,"灰"));
        master.feed(new Chick("坤坤",2,"黑白相间"));
        master.feed(new Fish("小鱼儿",3,"红"));



    }
}
